/**
 * 
 */
package com.googlecode.xcarve.config;

import org.apache.commons.lang3.StringUtils;

import com.alibaba.fastjson.JSONObject;
import com.googlecode.xcarve.common.config.CarveConstances;

/**
 * @author duxinyun
 *
 */
public class ConfigRefer extends Config{

	private int idleTimeMillis;
	private String coder;
	private int timeout;
	static final String default_coder = "hessian";
	
	public int getIdleTimeMillis() {
		return idleTimeMillis;
	}

	public void setIdleTimeMillis(int idleTimeMillis) {
		this.idleTimeMillis = idleTimeMillis;
	}

	public String getCoder() {
		if(StringUtils.isEmpty(coder)){
			return default_coder;
		}
		return coder;
	}

	public void setCoder(String coder) {
		this.coder = coder;
	}

	public int getTimeout() {
		return timeout;
	}

	public void setTimeout(int timeout) {
		this.timeout = timeout;
	}
	 
	protected String toConsumerPath() {
		StringBuilder path = new StringBuilder(CarveConstances.SEPTOR_PATH);
		path.append(CarveConstances.RPC_NAME).append(CarveConstances.SEPTOR_PATH)
		  .append(getDomain()).append(CarveConstances.SEPTOR_PATH)
		  .append(CarveConstances.RPC_CONSUMER_NAME).append(CarveConstances.SEPTOR_PATH)
		  .append(getInterfaceName()).append(CarveConstances.SEPTOR_PATH)
		  .append(JSONObject.toJSONString(this));
		return path.toString();
	}
}
